package com.reqresp; /**
 * @author wzm
 * @create 2023-09-20 10:09
 * project_name:javaweb2308
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/rs002")
public class RespServlet02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

//    @Override
//    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        //当访问Servlet的时候 返回HelloWord
//
//        //告诉浏览器我给你的是html类型的内容
////        response.setHeader("Content-type","text/html;charset=utf-8");
////        response.setCharacterEncoding("UTF-8");
//
//
//        //同时设置响应类型和编码的方法
//        response.setContentType("text/html;charset=UTF-8");
//
//
//        //1.获取字符输出流
//        PrintWriter writer = response.getWriter();
//        //输出简单字符串
////        writer.write("HelloWorld!!!!");
////        writer.write("HelloWorld!!!!");
////        writer.write("HelloWorld!!!!");
////        writer.write("HelloWorld!!!!");
//
//        //响应HTML形式
//
//
//        writer.write("<h1 style='color:red;'>你好</h1>");
//
//    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //Servlet以后得书写模版
        //1.解决乱码问题
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        //2.做相关的逻辑代码

        //3.响应具体的内容

    }

}
